<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/** @var \Magento\Review\Block\Adminhtml\Rating\Detailed $block */

?>
<?php if ($block->getRating() && $block->getRating()->getSize()): ?>
    <?php foreach ($block->getRating() as $_rating): ?>
    <div class="admin__field admin__field-rating">
        <label class="admin__field-label"><span><?php echo $block->escapeHtml($_rating->getRatingCode()) ?></span></label>
        <?php $_iterator = 1; ?>
        <?php $_options = ($_rating->getRatingOptions()) ? $_rating->getRatingOptions() : $_rating->getOptions() ?>
        <div class="admin__field-control" data-widget="ratingControl">
        <?php foreach (array_reverse($_options) as $_option): ?>
            <input type="radio" name="ratings[<?php echo $block->escapeHtmlAttr($_rating->getVoteId() ? $_rating->getVoteId() : $_rating->getId()) ?>]" id="<?php echo $block->escapeHtmlAttr($_rating->getRatingCode()) ?>_<?php echo $block->escapeHtmlAttr($_option->getValue()) ?>" value="<?php echo $block->escapeHtmlAttr($_option->getId()) ?>" <?php if ($block->isSelected($_option, $_rating)): ?>checked="checked"<?php endif; ?> />
            <label for="<?php echo $block->escapeHtmlAttr($_rating->getRatingCode()) ?>_<?php echo $block->escapeHtmlAttr($_option->getValue()) ?>">&#9733;</label>
        <?php $_iterator++ ?>
        <?php endforeach; ?>
        </div>
    </div>
    <?php endforeach; ?>
    <input type="hidden" name="validate_rating" class="validate-rating" value="" />
<script>
require([
    "jquery",
    "mage/mage",
    "Magento_Review/js/rating"
], function($){
    "use strict";

    $('[data-widget=ratingControl]').ratingControl();
});
</script>
<?php else: ?>
    <?php echo $block->escapeHtml(__("Rating isn't Available")) ?>
<?php endif; ?>
